﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace File24
{
    class TextInput
    {
        static public string userString = Console.ReadLine();
        static private string newDir = @"D:\Alena\New\";
        static public string NewDir { get { return newDir; } }

        static public void WriteToFile()
        {
            Console.WriteLine("Enter Text:");
            File.AppendAllText(@"D:\Alena\New\NewDocument.txt", userString);
        }

        static public void WordCalculator()
        {
            Directory.CreateDirectory(newDir);
            string[] files = Directory.GetFiles(newDir, "*.txt", SearchOption.TopDirectoryOnly);

            foreach (var NewDocument in files)
            {
                userString = File.ReadAllText(NewDocument);
                string[] wordsCalc = userString.Split(' ');
                Console.WriteLine("sum of words:");
                Console.WriteLine(wordsCalc.Length);
            }
        }
    }
}
